using System;
using Servlets.Attributes;
using Servlets.Exceptions;
using Servlets.Http;
using Servlets.Api;

namespace Servlets
{
	public static class EnumUtils
	{
		public static HttpMethod ParseToHttpMethod(this string self) {
			switch(self.ToLower()) {
				case "head": return HttpMethod.Head;
				case "get": return HttpMethod.Get;
				case "post": return HttpMethod.Post;
				case "put": return HttpMethod.Put;
				case "delete": return HttpMethod.Delete;
				case "trace": return HttpMethod.Trace;
				case "options": return HttpMethod.Options;
				case "connect": return HttpMethod.Connect;
				case "path": return HttpMethod.Path;
				default: throw new InvalidHttpMethodStringException(self);
			}
		}
	}
}

